﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using CacheHelp =JTicket.Common.CacheHelp;

using CrystalDecisions.Shared;
using CrystalDecisions.Web;

namespace JTicket.Config
{
    public class DBConfig
    {
        /// <summary>
        /// 获取全局网站数据库连接配置.
        /// </summary>
        public static string ApplicationString
        {
            get
            {
                if (CacheHelp.IsNull("ConnectionStrings_Collect"))
                {
                    CacheHelp.Insert(
                        "ConnectionStrings_Collect",
                        ConfigurationManager.ConnectionStrings["DBConncetion"].ConnectionString,120);
                }
                return (string)CacheHelp.Get("ConnectionStrings_Collect");
            }
        }

        /// <summary>
        /// 水晶报表登录
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="crs"></param>
        public static void CryLogin(string filePath, CrystalReportSource crs)
        {
            crs.ReportDocument.Load(filePath);
            crs.ReportDocument.SetDatabaseLogon(UIConfig.User,UIConfig.Password,UIConfig.Server,UIConfig.DataBase);
        }
        public static void SetCurrentValuesForParameterField(ParameterFields parameterFields, string strBlocId, string PraFileName)
        {
            ParameterValues currentParameterValues = new ParameterValues();
            ParameterDiscreteValue parameterDiscreteValue = new ParameterDiscreteValue();
            parameterDiscreteValue.Value = strBlocId;
            currentParameterValues.Add(parameterDiscreteValue);
            ParameterField parameterField = parameterFields[PraFileName];
            parameterField.CurrentValues = currentParameterValues;
        }

 
        

    }
}
